/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package planner;

import dao.ElectricityconsumptionDao;
import dao.InsuranceconsumptionDao;
import dao.MobileConsumptionDao;
import dao.MortgageconsumptionDao;
import dao.SalaryDao;
import dao.WaterconsumptionDao;
import domain.Electricityconsumption;
import domain.Electricitycontract;
import domain.Insuranceconsumption;
import domain.Insurancecontract;
import domain.Mobileconsumption;
import domain.Mobilecontract;
import domain.Mortgageconsumption;
import domain.Mortgagecontract;
import domain.Salary;
import domain.Userdom;
import domain.Waterconsumption;
import domain.Watercontract;
import domain.Wcontract;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Alberto
 */
public class Planner{

    public List createNotices(Userdom user) {
        List list = new ArrayList();
        Iterator it = null;
        Operations o = new Operations();
        //Facturas de movil
        List contratosMobiles = o.getMobileContrList(user);
        if (!contratosMobiles.isEmpty()) {
            it = contratosMobiles.iterator();
            while (it.hasNext()) {
                Mobilecontract cont = (Mobilecontract) it.next();
                Mobileconsumption mc = new MobileConsumptionDao().getMobileconsumptionDate(cont);
                if (mc == null) {
                    list.add("Añadir factura del móvil: " + cont.getContract().getNameContract());
                }
            }
        }
        //Facturas electricidad
        List contratosElec = o.getElecContrList(user);
        if (!contratosElec.isEmpty()) {
            it = contratosElec.iterator();
            while (it.hasNext()) {
                Electricitycontract cont = (Electricitycontract) it.next();
                Electricityconsumption ec = new ElectricityconsumptionDao().getElectricityconsumptionDate(cont);
                if (ec == null) {
                    list.add("Añadir factura de electricidad: " + cont.getContract().getNameContract());
                }
            }
        }
       
        //Agua
        List contratosAgua = o.getWaterContrList(user);
        if(!contratosAgua.isEmpty()){
            it = contratosAgua.iterator();
            while(it.hasNext()){
                Watercontract cont = (Watercontract) it.next();
                Waterconsumption wc = new WaterconsumptionDao().getWaterconsumptionDate(cont);
                if (wc == null){
                    list.add("Añadir factura de agua: " + cont.getContract().getNameContract());
                }
            }
        }

        //Seguros
        List contratosSeguros = o.getInsuranceContrList(user);
        if(!contratosSeguros.isEmpty()){
            it = contratosSeguros.iterator();
            while(it.hasNext()){
                Insurancecontract cont = (Insurancecontract) it.next();
                Insuranceconsumption ic = new InsuranceconsumptionDao().getInsuranceconsumptionDate(cont);
                if (ic == null){
                    list.add("Añadir factura de seguro: " + cont.getContract().getNameContract());
                }
            }
        }
        //Hipotecas
        List contratosHipotecas = o.getMortgageContrList(user);
        if(!contratosHipotecas.isEmpty()){
            it = contratosHipotecas.iterator();
            while(it.hasNext()){
                Mortgagecontract cont = (Mortgagecontract) it.next();
                Mortgageconsumption ic = new MortgageconsumptionDao().getMortgageconsumptionDate(cont);
                if (ic == null){
                    list.add("Añadir factura de hipoteca: " + cont.getContract().getNameContract());
                }
            }
        }
        //Salario
        List contratos = o.getWContrList(user);
        if(!contratos.isEmpty()){
            it = contratos.iterator();
            while(it.hasNext()){
                Wcontract cont = (Wcontract) it.next();
                Salary ic = new SalaryDao().getSalaryDate(cont);
                if(ic == null){
                    list.add("Revisar sueldo " +cont.getWorkName());
                }
            }
        }

        

        return list;
    }
}
